 
 
<!DOCTYPE html>
<html>
<head>
  <title>激活邮箱 - 麻雀博客</title>
  <#include "../common/link.ftl">
</head>
<body>

<#include "../common/header.ftl">

<div class="layui-container fly-marginTop fly-user-main">

  <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
        <li class="layui-nav-item">
            <a href="${ctx.contextPath}/user/home">
                <i class="layui-icon">&#xe68e;</i>
                我的主页
            </a>
        </li>
        <li class="layui-nav-item">
            <a href="${ctx.contextPath}/user/center">
                <i class="layui-icon">&#xe612;</i>
                用户中心
            </a>
        </li>
        <li class="layui-nav-item">
            <a href="${ctx.contextPath}/user/set/info">
                <i class="layui-icon">&#xe620;</i>
                基本设置
            </a>
        </li>
        <li class="layui-nav-item">
           <a href="${ctx.contextPath}/user/post">
              <i class="layui-icon layui-icon-form">&#xe63c;</i>
              我的博客
           </a>
        </li>
        <li class="layui-nav-item">
            <a href="${ctx.contextPath}/user/message">
                <i class="layui-icon">&#xe611;</i>
                我的消息
            </a>
        </li>
    </ul>
  <#include "../common/user-nav.ftl">

  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li class="layui-this">
          激活邮箱
        </li>
      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">
        <div class="layui-form layui-form-pane layui-tab-item layui-show">
         <#if (user.email!"")=="">
             <div class="layui-form-item">
                 <span class="layui-form-text">
                    <span style="color: #FF7200">您还未设定邮箱</span>，请去
                    <a class="layui-form-a" style="color:#4f99cf;"  href="${ctx.contextPath}/user/set/info">基本设置</a>
                    中设置邮箱。
                 </span>
             </div>
         <#else>
            <#if (user.activate!'') =="0"><!-- 未激活 -->
              <div class="layui-form-item">
                <label for="activate">您的邮箱：</label>
                <span class="layui-form-text" id="send_span">
                    ${user.email!''}
                    <em style="color:#c00;">（尚未激活）</em>
                    <a class="layui-form-a" style="color:#4f99cf;" href="javascript:send_activate_code();" >发送邮件</a>
                  </span>
            </div>
              <div id="input_div" class="layui-form-item">
                  <label for="active_code" class="layui-form-label">激活码</label>
                  <div class="layui-input-inline">
                      <input type="text" id="active_code" name="active_code" autocomplete="off" placeholder="输入激活码" class="layui-input">
                  </div>
              </div>
              <div id="btn_div" class="layui-form-item">
                  <button class="layui-btn" alert="1" lay-filter="*" id="activate_btn">激活</button>
              </div>
              <div id="content_div" class="layui-form-item">
                  <div>
                      1. 如果您未收到邮件，或激活链接失效，您可以
                      <a class="layui-form-a" style="color:#4f99cf;" id="LAY-activate" href="javascript:send_activate_code();">重新发送邮件</a>，或者
                      <a class="layui-form-a" style="color:#4f99cf;" href="${ctx.contextPath}/user/set/info">更换邮箱</a>；
                  </div>
                  <div>
                      2. 如果您始终没有收到 麻雀博客 发送的邮件，请注意查看您邮箱中的垃圾邮件；
                  </div>
                  <div>
                      3. 如果你实在无法激活邮件，您还可以联系：maque_blogs@163.com
                  </div>
              </div>
            <#else><!-- 已激活 -->
                <div class="layui-form-item">
                    <label for="activate">您的邮箱：</label>
                    <span class="layui-form-text" id="send_span">
                        ${user.email!''}<em style="color:#999;">（已成功激活）</em>
                     </span>
                </div>
            </#if>

         </#if>

        </div>
      </div>
    </div>
  </div>
  
</div>

<#include "../common/footer.ftl">

<script>

    var send_activate_code = function(){
        var email = "${user.email!''}";

        if (!email) {
            return;
        }
        var loading = layer.load();
        $.ajax({
            url: "${ctx.contextPath}/user/send_email",
            type: "post",
            data: {email: email},
            dataType: "json",
            success: function (result) {
                layer.close(loading);
                if (result.status == 0) {
                    error_msg(result.msg);
                } else {
                    success_msg(result.msg);
                }
            }
        });
    };

    $("#activate_btn").on("click", function () {
        var active_code = $("#active_code").val();
        if (!active_code) {
            return;
        }
        $.ajax({
            url: "${ctx.contextPath}/user/activate_email",
            type: "post",
            data: {activeCode: active_code},
            dataType: "json",
            success: function (result) {
                if (result.status == 0) {
                    $("#active_code").val("");
                    error_msg(result.msg);
                } else {
                    $("#send_span").empty();
                    $("#send_span").html("${user.email!''}<em style='color:#999;'>（已成功激活）</em>");
                    $("#input_div").remove();
                    $("#btn_div").remove();
                    $("#content_div").remove();
                    success_msg(result.msg);
                }
            }
        });
    });

</script>
</body>
</html>